package br.com.mucceli.politicapopular.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author mucceli
 */
@Entity
@Table(name = "ELEICAO")
@NamedQueries({
    @NamedQuery(name = "Eleicao.findAll", query = "SELECT e FROM Eleicao e"),
    @NamedQuery(name = "Eleicao.findByIdEleicao", query = "SELECT e FROM Eleicao e WHERE e.idEleicao = :idEleicao"),
    @NamedQuery(name = "Eleicao.findByAno", query = "SELECT e FROM Eleicao e WHERE e.ano = :ano"),
    @NamedQuery(name = "Eleicao.findByNumeroVotos", query = "SELECT e FROM Eleicao e WHERE e.numeroVotos = :numeroVotos")})
public class Eleicao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_ELEICAO")
    private Integer idEleicao;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ANO")
    private int ano;
    @Basic(optional = false)
    @NotNull
    @Column(name = "NUMERO_VOTOS")
    private int numeroVotos;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkEleicao")
    private Collection<Promessa> promessaCollection;
    @JoinColumn(name = "FK_POLITICO", referencedColumnName = "ID_POLITICO")
    @ManyToOne(optional = false)
    private Politico fkPolitico;
    @JoinColumn(name = "FK_CARGO", referencedColumnName = "ID_CARGO")
    @ManyToOne(optional = false)
    private Cargo fkCargo;

    public Eleicao() {
    }

    public Eleicao(Integer idEleicao) {
        this.idEleicao = idEleicao;
    }

    public Eleicao(Integer idEleicao, int ano, int numeroVotos) {
        this.idEleicao = idEleicao;
        this.ano = ano;
        this.numeroVotos = numeroVotos;
    }

    public Integer getIdEleicao() {
        return idEleicao;
    }

    public void setIdEleicao(Integer idEleicao) {
        this.idEleicao = idEleicao;
    }

    public int getAno() {
        return ano;
    }

    public void setAno(int ano) {
        this.ano = ano;
    }

    public int getNumeroVotos() {
        return numeroVotos;
    }

    public void setNumeroVotos(int numeroVotos) {
        this.numeroVotos = numeroVotos;
    }

    public Collection<Promessa> getPromessaCollection() {
        return promessaCollection;
    }

    public void setPromessaCollection(Collection<Promessa> promessaCollection) {
        this.promessaCollection = promessaCollection;
    }

    public Politico getFkPolitico() {
        return fkPolitico;
    }

    public void setFkPolitico(Politico fkPolitico) {
        this.fkPolitico = fkPolitico;
    }

    public Cargo getFkCargo() {
        return fkCargo;
    }

    public void setFkCargo(Cargo fkCargo) {
        this.fkCargo = fkCargo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEleicao != null ? idEleicao.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Eleicao)) {
            return false;
        }
        Eleicao other = (Eleicao) object;
        if ((this.idEleicao == null && other.idEleicao != null) || (this.idEleicao != null && !this.idEleicao.equals(other.idEleicao))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.mavenproject1.Eleicao[ idEleicao=" + idEleicao + " ]";
    }
    
}
